package dao

import (
	"yun_image/config/image"
	"yun_image/entity"
)

func CreateCategory(category *entity.Category) error {
	result := DB.Create(category)
	return result.Error
}

func DeleteCategory(id int, account string) error {
	result := DB.Model(&entity.Category{}).Where("id = ? and account = ?", id, account).Update("is_deleted", image.Deleted)
	return result.Error
}

func GetCategoriesByAccount(categories *[]entity.Category, account string) error {
	result := DB.Where("account = ? and is_deleted = ?", account, image.NotDeleted).Find(categories)
	return result.Error
}
